<?php

class DateUtils{
	
	private static $months = array("January",
						 		   "February",
								   "March",
								   "April",
						           "May",
								   "June", 
		    	                   "July",
		        	               "August",
	    	        	           "September",
	                    	 	   "October",
	                     		   "November",
	                     		   "December");
	
	public static function getMonthAsString($thisMonth){
		
		self::checkMonthIsValid($thisMonth);
		
		// 1 is subtracted because if the month was May, this would be
		// the 4th position in the array
		$thisMonth = (int) $thisMonth - 1;
		
		if(!is_int($thisMonth)){
			throw new Exception("thisMonth is not an integer");
		}
		
		return self::$months[$thisMonth];
	}
	
	/**
	 * returns the following month as a String 
	 * 
	 * @param int $thisMonth
	 * @return $nextMonth
	 * 
	 * @throws Exception if param is not a valid month
	 */
	public static function getNextMonthAsString($thisMonth){
		
		self::checkMonthIsValid($thisMonth);
		
		// 1 is subtracted because if the month was May, this would be
		// the 4th position in the array
		$thisMonth = (int) $thisMonth - 1;
		
		if(is_int($thisMonth)){

			if($thisMonth < 0 || $thisMonth > count(self::$months)){
				throw new Exception("integer month: " . $thisMonth . ", is invalid");
			}
			
			($thisMonth == 11) ? $nextMonth = self::$months[0] : $nextMonth = self::$months[$thisMonth+1];
			return $nextMonth;
		}
		
		throw new Exception("thisMonth is not an integer");
	}
	
	private static function checkMonthIsValid($month){
		
		if($thisMonth > 0 || $thisMonth < 13){
			return true;
		}
		
		throw new Exception("Integer: " . $thisMonth .", is out of bounds for month scope");
	}
}
?>